﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class TextArray : Form
    {
        public TextArray()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
            label1.Text = textBox1.Text;
        }
        int[] array = new int[100];
        int num = 0;
        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            array[num] = Convert.ToInt32(textBox1.Text);
            num++;
        }

        private void j(object sender, EventArgs e)
        {

        }

        private void button2_MouseClick(object sender, MouseEventArgs e)
        {
            int max = 0;
            foreach (int j in array)
            {

                if (j >= max)
                {
                    max = j;
                }
            }
            label3.Text =string.Concat( "最大值是：",Convert.ToString(max));

        }

        private void button3_MouseClick(object sender, MouseEventArgs e)
        {
            int min = 1000;
            for (int j = 0; j < num; j++)
            {
                if (array[j] < min)
                {
                    min = array[j];
                }
            }
            label3.Text = string.Concat("最小值是：", Convert.ToString(min));
        }

        private void button4_MouseClick(object sender, MouseEventArgs e)
        {
            
            for (int i = 0; i < 100; i++)
            {
                array[i] = 0;
            }
            num = 0;
        }

        private void button5_MouseClick(object sender, MouseEventArgs e)
        {
            int sum = 0;
            for (int j = 0; j < num; j++)
            {
                sum = sum + array[j];
            }
            int avg = sum / num;
            label3.Text = string.Concat("平均值是：", Convert.ToString(avg));
        }

        private void button6_MouseClick(object sender, MouseEventArgs e)
        {
            int sum = 0;
            for (int j = 0; j < num; j++)
            {
                sum = sum + array[j];
            }
           
            label3.Text = string.Concat("所有数组元素的和是：", Convert.ToString(sum));
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }
    }
}
